package com.lagou.controller;

import com.lagou.service.ArticleService;
import com.lagou.service.PageRequest;
import com.lagou.service.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("index")
public class IndexController {

    @Autowired
    ArticleService articleService;

    @RequestMapping("/list")
    public String findPage(Integer pageNum,Integer pageSize,Model model) {
        if (null == pageNum ) pageNum = 1;
        if (null == pageSize) pageSize=1;
        PageRequest pageQuery  = new PageRequest();
        pageQuery.setPageNum(pageNum);
        pageQuery.setPageSize(pageSize);
        PageResult page = articleService.findPage(pageQuery);
        model.addAttribute("page", page);
        return "client/index";
    }


}
